#include<bits/stdc++.h>
using namespace std;
int solve() {
  string buf; cin >> buf;
  vector<string> vs;
  sort(buf.begin(), buf.end());
  do{
    //cout << buf << endl;
    vs.push_back(buf);
  }while(next_permutation(buf.begin(), buf.end()));
  cout << vs.size() << endl;
  for(auto str:vs) cout << str << endl;
  return 0;
}
int main() {
  int tc;tc=1;
  for(int t=0;t<tc;++t) {
    solve();
  }
  return 0;
}
